{% extends "base_generic.html" %}

{% block title %}{% if object %}Edit Book{% else %}Create Book{% endif %}{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-8">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">
                    {% if object %}Edit Book: {{ object.title }}{% else %}Create New Book{% endif %}
                </h3>
            </div>
            <div class="panel-body">
                <form method="post">
                    {% csrf_token %}
                    
                    <div class="form-group">
                        <label for="{{ form.title.id_for_label }}">Title:</label>
                        {{ form.title }}
                        {% if form.title.errors %}
                            <div class="text-danger">{{ form.title.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="form-group">
                        <label for="{{ form.author.id_for_label }}">Author:</label>
                        {{ form.author }}
                        {% if form.author.errors %}
                            <div class="text-danger">{{ form.author.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="form-group">
                        <label for="{{ form.summary.id_for_label }}">Summary:</label>
                        {{ form.summary }}
                        {% if form.summary.errors %}
                            <div class="text-danger">{{ form.summary.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="form-group">
                        <label for="{{ form.isbn.id_for_label }}">ISBN:</label>
                        {{ form.isbn }}
                        {% if form.isbn.errors %}
                            <div class="text-danger">{{ form.isbn.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="form-group">
                        <label>Genre:</label>
                        {{ form.genre }}
                        {% if form.genre.errors %}
                            <div class="text-danger">{{ form.genre.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary">
                            {% if object %}Update Book{% else %}Create Book{% endif %}
                        </button>
                        <a href="{% if object %}{{ object.get_absolute_url }}{% else %}{% url 'books' %}{% endif %}" class="btn btn-default">Cancel</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %} 